<template>
  <div id="homes">
  <el-container>
  <el-header>
    <el-button type="info" plain class="posi" @click='fun'>|||</el-button>
    <div class="avat">
     
        <el-avatar  fit='contain' :src="url"></el-avatar>
    </div>
    <div class="divv">
      <img src="../assets/11111.jpg" alt="" class="im">
    </div>
    
    <h1>后台管理系统</h1>
      <el-button type="primary">主要按钮</el-button>
      <router-link to="/login">
      <el-button type="info" plain @click="clear">退出登录</el-button>
       </router-link>
  </el-header>

  <el-container>
    <el-aside :width="istrue?'44px':'200px'">
       <el-menu
      :default-active="paths"
    active-text-color='rgb(54, 24, 223)'
    :unique-opened='true'
    router
     >
      
       <el-submenu :index="itm.id+''" v-for="itm in list" :key='itm.id'>
        <template slot="title">
          <i  :class="ico[itm.id]"></i>
          <span>{{itm.authName}}</span>
        </template>
          <el-menu-item :index="'/'+itms.path" v-for="itms in itm.children" :key="itms.id" @click="getpath('/'+itms.path)">
             <i class="el-icon-menu" ></i>
            {{itms.authName}}</el-menu-item>
        
      </el-submenu>
     
    
    </el-menu>
    </el-aside>
    <el-main>
      <router-view/>
    </el-main>
  </el-container>
</el-container>

  </div>
</template>

<script>


export default {
  name: 'Home',
  created(){
   this.getlist()
   this.paths=window.sessionStorage.getItem('path')
   
  },
  methods:{
   clear(){
      window.sessionStorage.clear()
   },
   getlist(){
     this.$http.get('menus').then((res)=>{
       
      if (!res.status===200) return  this.$message.error('请求失败');
     
     this.list=res.data.data
      let token =res.config.headers.Authorization
      window.sessionStorage.setItem('tonke',token)

        
      
     })
   },
   getpath(val){
     console.log(val);
    window.sessionStorage.setItem('path',val)
   this.paths=val
   

   },
   fun(){
   this.istrue=!this.istrue
   }
  },
  components: {
  
  },
  data(){
    return{
       fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
       url:'../assets/11111.jpg',
       list:[],
       ico:{'125':'el-icon-s-custom','103':'el-icon-help','101':'el-icon-present','102':'el-icon-star-on','145':'el-icon-upload'},
       istrue:false,
       paths:''
    }
  }
}
</script>

<style lang='less' scoped>

 #homes{
  height: 100%;

.avat{
  width: 40px;
  height: 40px;
  position: absolute;
  top: 10px;
  left: 100px;
  
 
}



.el-header{
  display: flex;
  justify-content: space-around;
  align-items: center;
    background-color: #B3C0D1;
    
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    // text-align: center;
   
  }
  
  .el-container {
    width: 100%;
    height: 100%;
   
  }
  .divv{
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  .im{
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  .posi{
    position: absolute;
    top: 10px;
    left: 145px;
    font-weight: 900;
  }
  .el-menu{
    border-right: 0;
  }
  
  }
  
</style>
